package com.example.luge.composedemo

import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.luge.composedemo.component.ChatView
import com.example.luge.composedemo.component.NavHostApp
import com.example.luge.composedemo.more.ScrollableTabRowSimple
import com.example.luge.composedemo.ui.theme.ComposeDemoTheme

class MainActivity : ComponentActivity() {
    @OptIn(ExperimentalComposeUiApi::class)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

//        val topPadding:MutableState<Int> = mutableStateOf(10)
//        val animation = ObjectAnimator.ofInt(topPadding,"value",10,100);
//        animation.duration = 1000

//        val animator = ValueAnimator.ofInt(*values)
//        //添加监听
//        animator.addUpdateListener {
//            state.value = it.animatedValue as Int
//        }

//        var startPadding  = animateDpAsState(10.dp)
//
//        Box(modifier = Modifier
//            .padding(start = startPadding.value, top = topPadding.value.dp)
//            .size(100.dp)
//            .background(Color.Blue)
//            .clickable {
//                //animator.start()
//                startPadding.value = 100.dp
//
//            })

        setContent {
            ComposeDemoTheme(darkTheme = false){
                Surface( modifier = Modifier.fillMaxSize(),) {
                    //Greeting("Android")
//                   NavHostApp()

                    ChatView(listOf(
                        1.0,2.0,3.0,4.0
                    ), modifier = Modifier)
                    //ScrollableTabRowSimple()
                }
            }

//            ScrollDemo()
//            AnimationStateBox()
//            ComposeDemoTheme {
//                // A surface container using the 'background' color from the theme
//                Surface(
//                    modifier = Modifier.fillMaxSize(),
//                    color = MaterialTheme.colorScheme.background
//                ) {
//                    //Greeting("Android")
//
//                    Box(modifier = Modifier.padding().clickable {
//                        animation.start()
//                    })
//                    AnimationBox()
//                }
//            }
        }
    }
}



@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    ComposeDemoTheme {
        Greeting("Android")
    }
}